package com.she.iiicoursecenter.activity.tab3_reservation;

import java.util.List;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.she.iiicoursecenter.activity.template.TemplateActivity;
import com.she.iiicoursecenter.event.base.Event;
import com.she.iiicoursecenter.event.connect.bean.GetMakeBean;
import com.she.iiicoursecenter.event.connect.event.GetMakeEvent;
import com.she.iiicoursecenter.event.iface.IEventCallback;
import com.she.iiicoursecenter.eventmanager.KenEventManager;
import com.she.iiicoursecenter.view.tab3.Tab3_MainView;

public class Tab3_MainActivity extends TemplateActivity {
	//
	//
	private Tab3_MainView	mMainView;
	private ProgressDialog dialog ;
	public Tab3_MainActivity() {
		// TODO Auto-generated constructor stub
	}
	
	private Handler notifyHandler = new Handler(){
		@Override
		public void dispatchMessage(Message msg) {
			// TODO Auto-generated method stub
			dialog.cancel();
			mMainView.notifyAdapter();
			super.dispatchMessage(msg);
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		dialog = new ProgressDialog(this);
		 dialog.setMessage("讀取中...");
		 dialog.setIndeterminate(true);
		 dialog.setCancelable(true);
		 dialog.show();
		 
		mMainView = new Tab3_MainView(this);
		//
		setView(mMainView);
		setContentView(mMainView);		
		
		GetMakeEvent getMakeEvent = new GetMakeEvent();
		getMakeEvent.addCallback(new IEventCallback() {
			
			public void result(Event event, Object result) {
				// TODO Auto-generated method stub
				getApp().setGetMakeBeanData((List<GetMakeBean>) result);
				notifyHandler.sendEmptyMessage(0);
			}
			public void progress(Event event, int progress, String tmpPath) {
			}
		});
		KenEventManager.getInstance().execute(getMakeEvent);
		getApp().itemListColorCount = -1;
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

	@Override
	public void onAttachedToWindow() {
		// TODO Auto-generated method stub
		super.onAttachedToWindow();
	}

	@Override
	public void onDetachedFromWindow() {
		// TODO Auto-generated method stub
		super.onDetachedFromWindow();
	}

}
